package com.yuanchu.search.controller;

import com.yuanchu.common.utils.PageResult;
import com.yuanchu.common.utils.R;
import com.yuanchu.search.dto.QueryGoodsList;
import com.yuanchu.search.dto.QueryGoodsParamsDto;
import com.yuanchu.search.service.GoodsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @version: 1.0
 * @Author: adan
 * @description:
 * @date: 2024-03-11 18:02
 */
@RestController
@RequestMapping("goods")
public class GoodsSearchController {

    @Resource
    private GoodsService goodsService;

    @ApiOperation("查询商品列表接口")
    @GetMapping("/list")
    public R list(QueryGoodsParamsDto params) {
        if (params == null) {
            params = new QueryGoodsParamsDto();
        }
        PageResult<QueryGoodsList> pageResult = goodsService.queryGoodsList(params);
        HashMap<String, Object> map = new HashMap<>();
        map.put("list", pageResult);
        return R.ok().put("data", map);
    }
}
